package com.wn.app;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class SystemGenerator {
    public static void main(String[] args) {
        //修改路径  
        String path = "C:\\蜗牛学院\\07-java10\\code\\10-javacode\\sddfp\\sddfp-service\\sddfp-system-service";

        String pathCode = path + "\\src\\main\\java";
        String pathMapper = path + "\\src\\main\\resources\\mapper";

        // 连接数据库
        FastAutoGenerator.create(
                        "jdbc:mysql://192.168.190.154:3306/sddfp_system", "root", "root")

                .globalConfig(builder -> {
                    builder.author("yellow docker") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .disableOpenDir()
                            .outputDir(pathCode); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.wnxy.sddfp.system") // 设置父包名
                            .moduleName(null) // 设置父包模块名
                            .pathInfo(Collections.singletonMap(
                                    OutputFile.xml, pathMapper)); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.controllerBuilder().enableHyphenStyle().enableRestStyle();
                    builder.addInclude("u_user","u_user_detail") // 设置需要生成的表名
                            .addTablePrefix("u_"); // 设置过滤表前缀
                })
                .execute();
    }
}